package com.mc.web.controller.fil;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mc.common.annotation.Log;
import com.mc.common.core.controller.BaseController;
import com.mc.common.core.domain.AjaxResult;
import com.mc.common.enums.BusinessType;
import com.mc.fil.domain.FilIntoMaching;
import com.mc.fil.service.IFilIntoMachingService;
import com.mc.common.utils.poi.ExcelUtil;
import com.mc.common.core.page.TableDataInfo;

/**
 * 转入加工中心 Controller
 *
 * @author mc
 * @date 2021-04-14
 */
@RestController
@RequestMapping("/fil/maching")
public class FilIntoMachingController extends BaseController
{
    @Autowired
    private IFilIntoMachingService filIntoMachingService;

    /**
     * 查询转入加工中心 列表
     */
    @PreAuthorize("@ss.hasPermi('fil:maching:list')")
    @GetMapping("/list")
    public TableDataInfo list(FilIntoMaching filIntoMaching)
    {
        startPage();
        List<FilIntoMaching> list = filIntoMachingService.selectFilIntoMachingList(filIntoMaching);
        return getDataTable(list);
    }

    /**
     * 导出转入加工中心 列表
     */
    @PreAuthorize("@ss.hasPermi('fil:maching:export')")
    @Log(title = "转入加工中心 ", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FilIntoMaching filIntoMaching)
    {
        List<FilIntoMaching> list = filIntoMachingService.selectFilIntoMachingList(filIntoMaching);
        ExcelUtil<FilIntoMaching> util = new ExcelUtil<FilIntoMaching>(FilIntoMaching.class);
        return util.exportExcel(list, "maching");
    }

    /**
     * 获取转入加工中心 详细信息
     */
    @PreAuthorize("@ss.hasPermi('fil:maching:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(filIntoMachingService.selectFilIntoMachingById(id));
    }

    /**
     * 新增转入加工中心
     */
    @PreAuthorize("@ss.hasPermi('fil:maching:add')")
    @Log(title = "转入加工中心 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FilIntoMaching filIntoMaching)
    {
        return toAjax(filIntoMachingService.insertFilIntoMaching(filIntoMaching));
    }

    /**
     * 修改转入加工中心
     */
    @PreAuthorize("@ss.hasPermi('fil:maching:edit')")
    @Log(title = "转入加工中心 ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FilIntoMaching filIntoMaching)
    {
        return toAjax(filIntoMachingService.updateFilIntoMaching(filIntoMaching));
    }

}